package buffer

import (
	"bytes"
	"io"
	"io/ioutil"
)

// LoggerBuffer store log info in memory
type LoggerBuffer struct {
	buf *bytes.Buffer
}

//NewLoggerBuffer new LoggerBuffer instance
func NewLoggerBuffer() LoggerBuffer {
	loggerBuffer := LoggerBuffer{
		buf: &bytes.Buffer{},
	}
	return loggerBuffer
}

//GetLineLogMessage get line log message from buffer
func (lb *LoggerBuffer) GetLineLogMessage() ([]byte, error) {
	return ioutil.ReadAll(lb.buf)
}

func (lb *LoggerBuffer) GetWriter() io.Writer {
	return lb.buf
}
